package edu.nctu.csie.jichang.dp.behavioral;

public class Strategy {
	public static void main(String[] args) {
		String tContent = "This is A Strategy test Example";
		System.out.println(tContent);
		tContent = AbstractStrategy.replace(new StrategyUpperCase(tContent));
		System.out.println(tContent);
		tContent = AbstractStrategy.replace(new StrategyLowerCase(tContent));
		System.out.println(tContent);
	}
}
abstract class AbstractStrategy{
	String value;
	AbstractStrategy(String value){this.value = value;}
	abstract String doAlgo();
	public static String replace(AbstractStrategy strategy) {
		return strategy.doAlgo();
	}
}
class StrategyUpperCase extends AbstractStrategy{
	StrategyUpperCase(String value) {super(value);}
	String doAlgo() {return value.toUpperCase();}
}
class StrategyLowerCase extends AbstractStrategy{
	StrategyLowerCase(String value) {super(value);}
	String doAlgo() {return value.toLowerCase();}
}